﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class AddBook : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        BookShopDataContext db = new BookShopDataContext();
        if (Page.IsValid)
        {
            var categories = from c in db.BookInfo
                             where c.Book_Id == int.Parse(txtBookId.Text)
                             select c;
            if (categories != null)
            {
                foreach (BookInfo users in categories)
                {
                    lblMsg.Text = "此书籍已存在" ;
                }
                if (lblMsg.Text == "")
                {
                    //TODO:插入普通用户数据库表
                    sdsAddBook.Insert();
                    lblMsg.Text = "添加成功，请返回";
                }
            }
        }

    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("ManageBook.aspx");
    }
    protected void txtBookId_TextChanged(object sender, EventArgs e)
    {

    }
}